#include "DSP28x_Project.h"
#include "DSP2833x_PieCtrl.h"
#include "DSP2833x_PieVect.h"
#include "DSP2833x_Examples.h"

#include "dsp.h"


#define FLASH_RUN 1
#define SRAM_RUN 0
#define RUN_TYPE FLASH_RUN
#if RUN_TYPE == FLASH_RUN
extern Uint16 RamfuncsLoadStart;
extern Uint16 RamfuncsRunStart;
extern Uint16 RamfuncsLoadEnd;
#endif

void main()
{
    InitSysCtrl();
    EALLOW;
    GpioCtrlRegs.GPAMUX1.bit.GPIO0 = 0;
    GpioCtrlRegs.GPADIR.bit.GPIO0 = 1;
    GpioDataRegs.GPADAT.bit.GPIO0 = 0;
    EDIS;

    DINT;
    InitPieCtrl();
    IER = 0x0000;
    IFR = 0x0000;
    InitPieVectTable();
    EINT;

#if RUN_TYPE == FLASH_RUN
    MemCopy(&RamfuncsLoadStart,&RamfuncsLoadEnd,&RamfuncsRunStart);
    InitFlash();
#endif


    for(;;)
    {
        DELAY_US(500000);
        EALLOW;
        GpioDataRegs.GPATOGGLE.bit.GPIO0 = 1;
        EDIS;
    }
}

